package ca.uvic.cs.cogz.util;

import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

/**
 * Class for representing strings that are drawn into a Graphics object.
 * 
 * @author seanf
 */
public class StringItem {
	private Font font;
	private String text;

	public StringItem() {}

	public StringItem(String text, Font font) {
		this.text = text;
		this.font = font;
	}

	public int getHeight(Graphics2D g) {
		Rectangle2D bounds = font.getStringBounds(text, g.getFontRenderContext());

		return (int) bounds.getHeight();
	}

	public Rectangle2D getBounds(Graphics2D g) {
		return font.getStringBounds(text, g.getFontRenderContext());
	}

	public void draw(Graphics2D g, int x, int y) {
		g.setFont(font);
		g.drawString(text, x, y);
	}
}
